Change in openvpn[master]: NTLM: add length check to add_security_buffer
A message that is not in the archive (sent off-list or not yet received): gerrit.1705068839000.Icea931d29e3e504e23e045539b21013b42172664@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/496?usp=email
to review the following change.
Change subject: NTLM: add length check to add_security_buffer
......................................................................
NTLM: add length check to add_security_buffer
Especially ntlmv2_response can be very big, so make sure we not do exceed the size of the phase3 buffer.
---
M src/openvpn/ntlm.c
1 file changed, 9 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/496/1
src/openvpn/ntlm.c +9 -4
@@ -154,8 +154,13 @@static void add_security_buffer (int sb_offset,void *data,int length, -unsigned char *msg_buf,int *msg_bufpos) +unsigned char *msg_buf,int *msg_bufpos,size_t msg_bufsize) { +if (*msg_bufpos + length > msg_bufsize) + { +msg (M_WARN ,"NTLM: security buffer too big for message buffer" ); +return ; + }/* Adds security buffer data to a message and sets security buffer's * offset and length */ msg_buf[sb_offset] = (unsigned char )length;
@@ -362,15 +367,15 @@/* NTLMv2 response */ add_security_buffer (0x14 , ntlmv2_response, ntlmv2_blob_size +16 , - phase3, &phase3_bufpos); + phase3, &phase3_bufpos,sizeof (phase3));/* username in ascii */ add_security_buffer (0x24 , username,strlen (username), phase3, - &phase3_bufpos); + &phase3_bufpos,sizeof (phase3));/* Set domain. If <domain> is empty, default domain will be used * (i.e. proxy's domain) */ -add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos); +add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos,sizeof (phase3));/* other security buffers will be empty */ phase3[0x10 ] = phase3_bufpos;/* lm not used */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/496?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icea931d29e3e504e23e045539b21013b42172664
Gerrit-Change-Number: 496
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/496?usp=email )
Change subject: NTLM: add length check to add_security_buffer
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
Patchset:
PS1:
The code could use more fixes, but this is outside the scope of *this* patch - this does what it says: make sure the phase3 buffer is not overrun.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/496?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icea931d29e3e504e23e045539b21013b42172664
Gerrit-Change-Number: 496
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 08:59:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH 1/1 NTLM: add length check to add_security_buffer
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Especially ntlmv2_response can be very big, so make sure we not do exceed the size of the phase3 buffer.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/496
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ntlm.c +9 -4
@@ -154,8 +154,13 @@static void add_security_buffer (int sb_offset,void *data,int length, -unsigned char *msg_buf,int *msg_bufpos) +unsigned char *msg_buf,int *msg_bufpos,size_t msg_bufsize) { +if (*msg_bufpos + length > msg_bufsize) + { +msg (M_WARN ,"NTLM: security buffer too big for message buffer" ); +return ; + }/* Adds security buffer data to a message and sets security buffer's * offset and length */ msg_buf[sb_offset] = (unsigned char )length;
@@ -362,15 +367,15 @@/* NTLMv2 response */ add_security_buffer (0x14 , ntlmv2_response, ntlmv2_blob_size +16 , - phase3, &phase3_bufpos); + phase3, &phase3_bufpos,sizeof (phase3));/* username in ascii */ add_security_buffer (0x24 , username,strlen (username), phase3, - &phase3_bufpos); + &phase3_bufpos,sizeof (phase3));/* Set domain. If <domain> is empty, default domain will be used * (i.e. proxy's domain) */ -add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos); +add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos,sizeof (phase3));/* other security buffers will be empty */ phase3[0x10 ] = phase3_bufpos;/* lm not used */
[Openvpn-devel] [PATCH applied] Re: NTLM: add length check to add_security_buffer
This extra check makes sense, the code is not very robust here - maybe the wording of the message could be made more understandable (what does "security buffer too big for message buffer" mean?) but at least we have a check + message now.
I have not tested this for real as I do not have a working NTLM setup, but Frank has, and the code does not affect anything "not NTLM".
Your patch has been applied to the master branch.
The *check* needs to go into release/2.6 as well, but since the code is different (due to NTLMv1 removal) there is one extra add_security_buffer() to be handled by the 2.6 patch (gerrit/493). Coming next :-)
commit a021de2aabb21a24c7b69aaae1c710a9b6fee429 (master)
Author: Frank Lichtenheld Date: Wed Jan 17 09:59:51 2024 +0100
NTLM: add length check to add_security_buffer
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28037.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/496?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: NTLM: add length check to add_security_buffer
......................................................................
NTLM: add length check to add_security_buffer
Especially ntlmv2_response can be very big, so make sure we not do exceed the size of the phase3 buffer.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28037.html
---
M src/openvpn/ntlm.c
1 file changed, 9 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/496/2
src/openvpn/ntlm.c +9 -4
@@ -154,8 +154,13 @@static void add_security_buffer (int sb_offset,void *data,int length, -unsigned char *msg_buf,int *msg_bufpos) +unsigned char *msg_buf,int *msg_bufpos,size_t msg_bufsize) { +if (*msg_bufpos + length > msg_bufsize) + { +msg (M_WARN ,"NTLM: security buffer too big for message buffer" ); +return ; + }/* Adds security buffer data to a message and sets security buffer's * offset and length */ msg_buf[sb_offset] = (unsigned char )length;
@@ -362,15 +367,15 @@/* NTLMv2 response */ add_security_buffer (0x14 , ntlmv2_response, ntlmv2_blob_size +16 , - phase3, &phase3_bufpos); + phase3, &phase3_bufpos,sizeof (phase3));/* username in ascii */ add_security_buffer (0x24 , username,strlen (username), phase3, - &phase3_bufpos); + &phase3_bufpos,sizeof (phase3));/* Set domain. If <domain> is empty, default domain will be used * (i.e. proxy's domain) */ -add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos); +add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos,sizeof (phase3));/* other security buffers will be empty */ phase3[0x10 ] = phase3_bufpos;/* lm not used */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/496?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icea931d29e3e504e23e045539b21013b42172664
Gerrit-Change-Number: 496
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/496?usp=email )
Change subject: NTLM: add length check to add_security_buffer
......................................................................
NTLM: add length check to add_security_buffer
Especially ntlmv2_response can be very big, so make sure we not do exceed the size of the phase3 buffer.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28037.html
---
M src/openvpn/ntlm.c
1 file changed, 9 insertions(+), 4 deletions(-)
src/openvpn/ntlm.c +9 -4
@@ -154,8 +154,13 @@static void add_security_buffer (int sb_offset,void *data,int length, -unsigned char *msg_buf,int *msg_bufpos) +unsigned char *msg_buf,int *msg_bufpos,size_t msg_bufsize) { +if (*msg_bufpos + length > msg_bufsize) + { +msg (M_WARN ,"NTLM: security buffer too big for message buffer" ); +return ; + }/* Adds security buffer data to a message and sets security buffer's * offset and length */ msg_buf[sb_offset] = (unsigned char )length;
@@ -362,15 +367,15 @@/* NTLMv2 response */ add_security_buffer (0x14 , ntlmv2_response, ntlmv2_blob_size +16 , - phase3, &phase3_bufpos); + phase3, &phase3_bufpos,sizeof (phase3));/* username in ascii */ add_security_buffer (0x24 , username,strlen (username), phase3, - &phase3_bufpos); + &phase3_bufpos,sizeof (phase3));/* Set domain. If <domain> is empty, default domain will be used * (i.e. proxy's domain) */ -add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos); +add_security_buffer (0x1c , domain,strlen (domain), phase3, &phase3_bufpos,sizeof (phase3));/* other security buffers will be empty */ phase3[0x10 ] = phase3_bufpos;/* lm not used */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/496?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icea931d29e3e504e23e045539b21013b42172664
Gerrit-Change-Number: 496
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged